package com.auth.manage.common.order.api.request;

import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class OrderCreateRequest {

    /**
     * 买家id
     */
    @NotNull(message = "买家id不能为空")
    private Long buyerId;

    /**
     * 卖家id
     */
    @NotNull(message = "卖家id不能为空")
    private Long sellerId;

    /**
     * 订单金额
     */
    @DecimalMin(value = "0.0", inclusive = false, message = "订单金额必须大于0")
    private BigDecimal orderAmount;

    /**
     * 商品Id
     */
    @NotNull(message = "商品Id不能为空")
    private Long productId;

    /**
     * 商品图片
     */
    private String productPicUrl;


    /**
     * 商品名称
     */
    private String productName;


    /**
     * 商品数量
     */
    @Min(value = 1)
    private int itemCount;

    /**
     * 商品单价
     */
    // inclusive = false不包含边界，要>0
    @DecimalMin(value = "0.0", inclusive = false, message = "商品单价必须大于0")
    private BigDecimal itemPrice;

    public void create(Long buyerId, Long sellerId, BigDecimal orderAmount, Long productId, String productPicUrl, String productName, int itemCount, BigDecimal itemPrice) {
        this.buyerId = buyerId;
        this.sellerId = sellerId;
        this.orderAmount = orderAmount;
        this.productId = goodsId;
        this.productPicUrl = goodsPicUrl;
        this.productName = goodsName;
        this.itemCount = itemCount;
        this.itemPrice = itemPrice;
    }
}
